package physics;

import graphics.GraphicsLib;
import graphics.Node;

import java.util.ArrayList;
import java.util.Collection;

public final class PhysicsLib {
	
	public static Collection<PhysicsObject> getObjects() {
		final ArrayList<PhysicsObject> list = new ArrayList<PhysicsObject>();
		//list.add(getBall(0, 0.7f));
		//list.add(getBall(0.05f, 0.5f));
		final float[][] points = {{.7f, .7f}, {.8f, .7f}, {.75f, .8f}};
		final float[] points2 = {-.1f, -.1f, .1f, -.1f, 0, .1f};
		final float[] points3 = {.3f, .3f, .9f, .3f, .4f, .5f};
		list.add(getTriangle(null , 1));
		list.add(getBottom());
		list.add(getTop());
		list.add(getLeft());
		list.add(getRight());
		return list;
	}
	
	public static Triangle getTriangle(final float[] the_points, 
			final float inverse_mass) {
		//final Node graphic = GraphicsLib.getTriangle(the_points, 1f, 1f, 1f);
		final Triangle triangle = new Triangle(1);
		triangle.position.x = -.1f;
		triangle.position.y = -.1f;
		triangle.acceleration.x = 1f;
		triangle.velocity.y = 1f;
		triangle.angularVelocity = .1f;
		return triangle;
	}

	private static HalfSpace getBottom() {
		final HalfSpace bottom = new HalfSpace(new Vector2f(0, -1), 
				new Vector2f(0, 1));
		return bottom;
	}
	
	private static HalfSpace getTop() {
		final HalfSpace bottom = new HalfSpace(new Vector2f(0, 1), 
				new Vector2f(0, -1));
		return bottom;
	}
	
	private static HalfSpace getRight() {
		final HalfSpace bottom = new HalfSpace(new Vector2f(1,0), 
				new Vector2f(-1, 0));
		return bottom;
	}
	
	private static HalfSpace getLeft() {
		final HalfSpace bottom = new HalfSpace(new Vector2f(-1, 0), 
				new Vector2f(1, 0));
		return bottom;
	}

	private static Circle getBall(final float x, final float y) {
		final Node single_graphic = GraphicsLib.getCircle(90);
		single_graphic.setScale(0.1f, 0.1f, 0.1f);
		single_graphic.setTranslate(x, y, 0);
		final Circle single = new Circle(0.1f , single_graphic);
		single.position.x = x;
		single.position.y = y;
		single.acceleration.y = -1.3f;
		single.velocity.y = -1f;
		//single.velocity[0] = -1f;
		return single;
	}

}
